//
//  EJSMineHeaderView.m
//  24Gou
//
//  Created by lifayu on 2018/11/2.
//  Copyright © 2018 lifayu. All rights reserved.
//

#import "EJSMineHeaderView.h"
#import <UIButton+WebCache.h>

@implementation EJSMineHeaderView

+ (EJSMineHeaderView *)mineHeaderView{
    
    EJSMineHeaderView *headerView = [[UINib nibWithNibName:@"EJSMineHeaderView" bundle:nil] instantiateWithOwner:self options:nil].firstObject;
    return headerView;
}

- (void)awakeFromNib{
    [super awakeFromNib];
    self.loginNameLabel.text = NSLocalizedString(@"立即登录", nil);
    self.userInfoBtn.titleLabel.font = CHINESE_PingFangMedium(17);
    self.userInfoBtn.imageView.cornerRadius = 30;
    self.userInfoBtn.imageSize = CGSizeMake(60, 60);
    self.userInfoBtn.padding = CGSizeMake(15, 0);
    self.userInfoBtn.style = EImageLeftTitleRightLeft;
}

- (void)refreshUserInfo{
    if([EJSUserTokenModel userTokenModel]){
        self.userInfoView.hidden = NO;
        self.loginView.hidden = YES;
        
        EJSUserModel *userInfo = [EJSUserModel userModel];
        [self.userInfoLabel setTitle:userInfo.name?userInfo.name:userInfo.phone forState:UIControlStateNormal];
        [self.userInfoBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:userInfo.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"user_btn"]];
        if(userInfo.levelId.integerValue > 1){
            self.vipVIew.hidden = YES;
        }else{
            self.vipVIew.hidden = NO;
        }
    }else{
        self.userInfoView.hidden = YES;
        self.loginView.hidden = NO;
    }
        self.vipVIew.hidden = YES;
}

@end
